<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text"/>
    <button id="myBtn">焦点测试</button>
</body>
<script>
    const myBtn = document.querySelector('#myBtn');
    myBtn.addEventListener('click',(event)=>{
        console.log('event',event.target); //event  <button id="myBtn">焦点测试</button>
        console.log('document.hasFocus()',document.hasFocus()); //document.hasFocus() true
        console.log('document.activeElement',document.activeElement);//document.activeElement <button id=​"myBtn">​焦点测试​</button>​
    })
</script>
</html>